<script>
export default {
  name: "GView"
}
</script>

<template>
  <h1>计算器练习</h1>
  <input type="text" v-model="n1" placeholder="请输入数字1">
  <input type="text" v-model="n2" placeholder="请输入数字2" >
  <hr>
  <button @click="f('+')">加</button>
  <button @click="f('-')">减</button>
  <button @click="f('*')">乘</button>
  <button @click="f('/')">除</button>
  <h3>运算结果：{{res}}</h3>
</template>
<script setup>
import {ref} from "vue";

const n1 = ref('');
const n2 = ref('');
const res = ref('');


const f = (o) => {
  res.value = eval(n1.value+o+n2.value);
}
</script>

<style scoped>

</style>